package com.cskaoyan.execution;

import com.cskaoyan.bean.MarketAdmin;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author stone
 * @date 2023/04/06 09:05
 */
public class TypeHandlerExecution {

    public static void main(String[] args) throws SQLException {
        //executeQuery();
        //executeInsert();
    }

    private static void executeInsert() throws SQLException {
        /*Connection connection = null;
        String sql = "insert into market_admin (id, username, password, \n" +
                "      last_login_ip, last_login_time, avatar, \n" +
                "      add_time, update_time, deleted, \n" +
                "      role_ids) values (?,?,?,?,?,?,?,?,?,?)";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setInt(1,5);
        preparedStatement.setString(2,"zhangsan");
        // ....
        MarketAdmin admin = new MarketAdmin();
        Integer[] roleIds = admin.getRoleIds();
        // Integer[] → String
        preparedStatement.setString(10,roleIdsStr);*/

    }

    private static void executeQuery() throws SQLException {
        /*Connection connection = null;
        String sql = "select * from market_admin ";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        ResultSet resultSet = preparedStatement.executeQuery();
        resultSet.next();
        String roleIdsStr = resultSet.getString("role_ids");
        MarketAdmin marketAdmin = new MarketAdmin();
        // String → Integer[]
        // [1,2,3]  Jackson
        marketAdmin.setRoleIds(roleIdsStr);*/
    }
}
